package com.sunda.spmsoversea.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.sunda.spmsoversea.entity.OverseaWhsInDtl;
import com.sunda.spmsoversea.mapper.OverseaWhsInDtlMapper;
import com.sunda.spmsoversea.service.IOverseaWhsInDtlService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 海外仓入库任务明细 服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-08-26
 */
@Service
public class OverseaWhsInDtlServiceImpl extends ServiceImpl<OverseaWhsInDtlMapper, OverseaWhsInDtl> implements IOverseaWhsInDtlService {

    @Override
    public int addOverseaWhsInDtl(OverseaWhsInDtl overseaWhsInDtl) {
        if (overseaWhsInDtl == null){
            return -1;
        }
        return this.baseMapper.insert(overseaWhsInDtl);
    }

    @Override
    public List<Map<String, Object>> getOverseaWhsInDtlList(String uuidWhsIn) {
        if (StringUtils.isEmpty(uuidWhsIn)){
            return null;
        }
        return this.baseMapper.getOverseaWhsInDtlList(uuidWhsIn);
    }

    @Override
    public OverseaWhsInDtl getOverseaWhsInDtl(int autoIdWhsInDtl) {
        QueryWrapper<OverseaWhsInDtl> queryWrapper = new QueryWrapper<OverseaWhsInDtl>().eq("AUTO_ID_WHS_IN_DTL", autoIdWhsInDtl);
        return this.baseMapper.selectOne(queryWrapper);
    }

    @Override
    public int updateOverseaWhsInDtl(OverseaWhsInDtl overseaWhsInDtl) {
        if (overseaWhsInDtl == null){
            return -1;
        }
        int autoIdWhsInDtl = overseaWhsInDtl.getAutoIdWhsInDtl();
        QueryWrapper<OverseaWhsInDtl> queryWrapper = new QueryWrapper<OverseaWhsInDtl>().eq("AUTO_ID_WHS_IN_DTL", autoIdWhsInDtl);
        return this.baseMapper.update(overseaWhsInDtl, queryWrapper);
    }

    @Override
    public List<OverseaWhsInDtl> getOverseaWhsInDtls(String uuidWhsIn) {
        if (StringUtils.isEmpty(uuidWhsIn)){
            return null;
        }
        QueryWrapper<OverseaWhsInDtl> queryWrapper = new QueryWrapper<OverseaWhsInDtl>().eq("UUID_WHS_IN", uuidWhsIn);
        return this.baseMapper.selectList(queryWrapper);
    }
}
